﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Sisocana.Core.Models;
using Sisocana.Core.Interfaces;
using Sisocana.Dal.Interfaces;
using Sisocana.Dal.EntityModels;
using Sisocana.Dal;

namespace Sisocana.Core
{
    public class NoticiasService : ServiceBase<NoticiaModel>, INoticiasService
    {
        private INoticiasRepository _noticiasRepository;

        public NoticiasService()
            : this(new NoticiasRepository())
        {
        }

        public NoticiasService(INoticiasRepository noticiasRepository)
        {
            _noticiasRepository = noticiasRepository;
        }

        public void createNoticiasMapperEF2Model()
        {
            AutoMapper.Mapper.CreateMap<Noticias, NoticiaModel>();
        }

        public void createNoticiasMapperModel2EF()
        {
            AutoMapper.Mapper.CreateMap<NoticiaModel, Noticias>();
        }

        NoticiaModel IService<NoticiaModel>.GetSingle(System.Linq.Expressions.Expression<Func<NoticiaModel, bool>> whereCondition)
        {
            throw new NotImplementedException();
        }



        void IService<NoticiaModel>.Add(NoticiaModel entity)
        {
            throw new NotImplementedException();
        }

        void IService<NoticiaModel>.Delete(NoticiaModel entity)
        {
            throw new NotImplementedException();
        }

        void IService<NoticiaModel>.Update(NoticiaModel entity)
        {
            throw new NotImplementedException();
        }

        IList<NoticiaModel> IService<NoticiaModel>.GetAll(System.Linq.Expressions.Expression<Func<NoticiaModel, bool>> whereCondition)
        {
            createNoticiasMapperEF2Model();

            IList<Noticias> noticiasEF = _noticiasRepository.GetAll();
            List<NoticiaModel> noticias = new List<NoticiaModel>();

            noticias = AutoMapper.Mapper.Map(noticiasEF, noticias);

            IQueryable<NoticiaModel> noticiasRet = noticias.AsQueryable<NoticiaModel>().Where(whereCondition);

            return noticiasRet.ToList();
        }

        IList<NoticiaModel> IService<NoticiaModel>.GetAll()
        {
            createNoticiasMapperEF2Model();

            IList<Noticias> noticiasEF = _noticiasRepository.GetAll();
            List<NoticiaModel> noticias = new List<NoticiaModel>();

            noticias = AutoMapper.Mapper.Map(noticiasEF, noticias);

            return noticias.ToList();
        }

        IQueryable<NoticiaModel> IService<NoticiaModel>.Query(System.Linq.Expressions.Expression<Func<NoticiaModel, bool>> whereCondition)
        {
            throw new NotImplementedException();
        }

        long IService<NoticiaModel>.Count(System.Linq.Expressions.Expression<Func<NoticiaModel, bool>> whereCondition)
        {
            throw new NotImplementedException();
        }

        long IService<NoticiaModel>.Count()
        {
            throw new NotImplementedException();
        }
    }
}
